﻿using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Locator.Common.DataAccess;

namespace Locator.Common.UnitTests
{
    [TestFixture]
    public class TestPoc : TestPocBase
    {
        [Test]
        public void Test1()
        {
            Assert.AreEqual(3, this.UnitOfWork.Stores.FindAll().Count());
        }

        [Test]
        public void Test2()
        {
            Assert.AreNotEqual(4, this.UnitOfWork.Stores.FindAll().Count());
        }

        [Test]
        public void Test3()
        {
            var user1 = this.UnitOfWork.Users.FindById(1);
            Assert.AreEqual(2, user1.Stores.Count);
        }

        [Test]
        public void Test4()
        {
            Assert.AreEqual(1, this.UnitOfWork.Users.FindAll().Count());
            Assert.AreEqual(2, this.UnitOfWork.Users.FindById(1).Stores.Count);
            var store = this.UnitOfWork.Stores.FindById(3);
            this.UnitOfWork.Users.FindById(1).Stores.Add(store);
            this.UnitOfWork.Commit();
            Assert.IsTrue(this.UnitOfWork.Committed);
            Assert.AreEqual(3, this.UnitOfWork.Users.FindById(1).Stores.Count);
        }

        [TestFixtureTearDown]
        public void Cleanup()
        {
            this.UnitOfWork.Dispose();
        }
    }
}
